package com.zhouys.relection;

//什么叫反射
public class Test1 {
    public static void main(String[] args) throws ClassNotFoundException {
//        通过反射获取的class对象
        Class<?> c1 = Class.forName("com.zhouys.relection.User");
        Class<?> c2 = Class.forName("com.zhouys.relection.User");
        Class<?> c3 = Class.forName("com.zhouys.relection.User");
        Class<?> c4 = Class.forName("com.zhouys.relection.User");
//        一个类在内存中只有一个class对象
//        一个类被加载后  类的整个结构都会被封装到内存中
        System.out.println(c1.hashCode()+"sadg");
        System.out.println(c2.hashCode()+"sadg");
        System.out.println(c3.hashCode()+"sadg");
        System.out.println(c4.hashCode()+"sadg");

    }
}

//实体类
class  User{
    private  String name;
    private  int id;
    private  int age;

    public User() {
        this.name = name;
        this.id = id;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", id=" + id +
                ", age=" + age +
                '}';
    }
}
